package com.lhc.nacosprovider.controller;

import io.github.biezhi.ome.OhMyEmail;
import io.github.biezhi.ome.SendMailException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;

import static io.github.biezhi.ome.OhMyEmail.SMTP_QQ;

/**
 * @author liuchaoqun
 * @date 2022/6/20
 * @Description 邮件
 */
@RestController
public class EmailController {

    private static final String TO_EMAIL = "2190401566@qq.com";

    @PostConstruct
    public void init() {
        // 配置，一次即可 your@password不是指QQ邮箱的密码，是指QQ邮箱的授权码
        OhMyEmail.config(SMTP_QQ(false), "1069320627@qq.com", "ptwogmxffccqbcae");
    }

    @GetMapping("testSendText")
    public String testSendText() throws  SendMailException {
        OhMyEmail.subject("这是一封测试TEXT邮件")
                .from("小姐姐的邮箱")
                .to(TO_EMAIL)
                .text("信件内容")
                .send();
        return "发送成功";
    }



}
